import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:kepu/provider/theme_provider.dart';
import 'package:kepu/util/constant/route_name.dart';
import 'package:kepu/util/http_util.dart';
import 'package:kepu/util/route.dart';
import 'package:kepu/util/theme_util.dart';

void main() {
  DioInstance.instance().initDio(baseUrl: "http://localhost:8081/app/");
  runApp(ProviderScope(child: const MyApp()));
}

class MyApp extends ConsumerWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    var isLightMode = ref.watch(isLightModeProvider);
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: isLightMode ? ThemeUtil.lightTheme : ThemeUtil.darkTheme,
      onGenerateRoute: (settings) => AppPages.generateRouteSettings(settings),
      initialRoute: RouteName.ROOT,
    );
  }
}
